﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using Koopakiller.Numerics.Addins;

namespace Koopakiller.Numerics.StringParser
{
    public class Function
    {
        public Function()
        {
            this.functions = new Dictionary<string, IFunctionObject>();
        }

        public void LoadAssembly(string assemblyName)
        {
            Assembly asm = Assembly.Load(assemblyName);
            var interfaceType = typeof(IFunctionObject);
            foreach (var type in asm.GetTypes().Where(x => x.GetInterfaces().Contains(interfaceType)))
            {
                var item = Activator.CreateInstance(type) as IFunctionObject;
                this.functions.Add(item.FunctionName, item);
            }
        }

        /// <summary>
        /// Die Liste mit geladenen Funktionen.
        /// </summary>
        Dictionary<string, IFunctionObject> functions;
    }
}
